<?php 
header("Content-Type: text/html; charset=UTF-8");
session_start();

$file_alias=@$_GET['file_alias'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>gd</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {
	font-weight: bold;
}
.style11 {	COLOR: #000000
}
body {
	margin-left: 0px;
	margin-top: 0px;
}
-->
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkfile(){
	if(document.addFile.UploadFile.value==""){
		alert("请选择要上传的会议附件！");
		document.addFile.UploadFile.focus();
		return false;
	}
	return true;
}

var isflag=false;
function uploadfile()
{
	var filename = document.addFile.UploadFile.value;
	document.addFile.path.value=filename;
	var pattern=/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/;
	var exts = filename.substr(filename.length-3,3).toLowerCase();
	
	 if(!isflag){
	   //alert(isflag);
		if(exts=='jpg'||exts=='JPG'||exts=='gif'||exts=='GIF'||exts=='png'||exts=='PNG'){
		//if(/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(exts))
			//if(CheckFileSize(filename)){
					isflag=true;
					addFile.submit();
					return   true;
			//}
		}else{
			alert("Sorry ,Please upload jpg and gif format Banner !");
			location.href="uploadAds.php";
		}
	}
}
function startUpLoad()
{
	var filename = document.addFile.UploadFile.value;
	document.addFile.path.value=filename;
	document.getElementById("upload").style.display='';
	uploadfile();
}

function CheckFileSize(f)
{
	var img=null;
	img=document.createElement("img");
	document.body.insertAdjacentElement("beforeend",img);
	img.style.visibility="hidden"; 
	img.src=f;
	var imgwidth=img.offsetWidth;
	var imgheight=img.offsetHeight;
	
	if(imgwidth>130||imgheight>30)
	{
		alert("Sorry, Banner size should be resize to  130 * 30 only !");
		location.href="uploadAds.php";
		return false;
	}
	return true;
}
var alias='<?=$file_alias?>';
function AddOne(){
	document.getElementById("btnPrev").style.display='';
	document.addFile.path.value=alias;
	parent.document.getElementById("UpFileList").value=alias;
}

function Okway_Previewa()
{
	var nwin = window.open('../uploadfile/'+alias,'preview','width=300,height=200,scrollbars=yes,resizable=yes');
}

function Okway_Delete()
{
}
//-->
</script>
 <style>
div.fileinputs { position: relative;padding-top: 8px; height:30px}div.fakefile { position: absolute; top: 0px; left: 0px; z-index: 1;}input.file { position: relative;top: -6px; left: 0px; text-align: right; -moz-opacity:0 ; filter:alpha(opacity: 0); opacity: 0; z-index: 2;}
</style>
</head>
<body onload="<?php if($file_alias!=""){?>AddOne();<? }?>">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <form  action="upfile_subdo.php" name="addFile" method="post" enctype="multipart/form-data"><tr>
    <td width="240" valign="bottom" align="absmiddle" style="margin-bottom:6px;">
	<div class="fileinputs" >
		<input name="UploadFile" class="file" height="30" id="UploadFile"  type="file" style="border:1px solid #0084CF" contenteditable="false" onPropertyChange="startUpLoad();"/>
	<div class="fakefile"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input name="path" readonly></td>
    <td style="padding-left:8px;cursor:pointer"><img src="browse.jpg" style="cursor:default"/></td>
	<td>&nbsp;<input type="button" value="upload" onClick="uploadfile();" class="button" id="upload" style="display:none;height: 24px;"></td>
	<td>&nbsp;<input type="button" value="Del" onClick="Okway_Delete()" class="button" id="btnDel" style="display:none;height: 24px;"></td>
	<td>&nbsp;<input type="button" value="View" onClick="Okway_Previewa();" class="button" id="btnPrev" style="display:none;height: 24px;"></td>
  </tr>
</table></div>
	</div></td>
    <td align='absmiddle' style="padding-top:2px;" valign="baseline">
	</td>
  </tr>
  </form>
</table>
</body>
</html>
